import numpy as np
import pandas as pd
import time
from datetime import datetime


def dtypes_to_str(dtypes):
  types = {}
  print(dtypes)
  for (column, dtype) in dtypes.items():
    if dtype == 'float16' or dtype == 'float32':
      types[column] = 'FLOAT'
    elif dtype == 'float64':
      types[column] = 'DOUBLE'
    elif dtype == 'int8' or dtype == 'uint8' or dtype == 'int16' \
        or dtype == 'uint16' or dtype == 'int32' or dtype == 'uint32':
      types[column] = 'INTEGER'
    elif dtype == 'int64' or dtype == 'uint64':
      types[column] = 'BIGINT'
    elif 'bool' in str(dtype):
      types[column] = 'BOOLEAN'
    elif 'datetime64' in str(dtype):
      types[column] = 'TIMESTAMP'
    else:
      types[column] = 'STRING'
  return types


dates = pd.date_range('20170101', periods=7)
print(dates)
print("--" * 26)
df = pd.DataFrame(np.random.randn(70, 4), index=None, columns=list('ABCD'))
print(df)
print(df.describe())
print(df.dtypes['A'] == 'float64')

df1 = pd.DataFrame(np.array(
  [[1, datetime.now(), 3], [4, datetime.now(), 6], [7, datetime.now(), 9]]),
                   columns=['a', 'b', 'c'])
print(type(datetime.now()))
print(type(time.localtime()))
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
print(dtypes_to_str(df1.dtypes))
for (index, row) in df1.iterrows():
  print("===========================")
  print(row['a'], row['b'], row['c'])
